package com.booksystem.campuslibrarymanagementsystem.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.booksystem.campuslibrarymanagementsystem.entity.AccountTable;
import com.booksystem.campuslibrarymanagementsystem.entity.CategoriesTable;
import com.booksystem.campuslibrarymanagementsystem.entity.UserTable;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

@Mapper
public interface CategoriesTableMapper extends BaseMapper<CategoriesTable> {
//查询-类别
    @Select("select * from categories_table where categoryname = #{categoryname}")
    CategoriesTable queryByCategoryName(String categoryname);

    //查询-id
    @Select("select * from categories_table where categoryid = #{categoryid}")
    CategoriesTable queryByCategoryId(int categoryid);

    //更新名称
    @Update("update categories_table set categoryname = #{categoryname} where categoryid= #{categoryid}")
    boolean upDataName(int categoryid,String categoryname);

    //删除
    @Delete("delete from categories_table where categoryid = #{categoryid}")
    boolean deleteByIds(int categoryid);

    //获取最后一条数据的categoryid
    @Select("SELECT * FROM categories_table ORDER BY categoryid DESC LIMIT 1")
    CategoriesTable selectLastCategoryid();
}
